package initialize

import (
	"GIN-API/global"
	"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

// 初始化OSS客户端
func InitOSS() {
	// 获取OSS配置
	accessKeyID := global.Cfg.OSSAccessKeyId
	accessKeySecret := global.Cfg.OSSAccessKeySecret
	endpoint := global.Cfg.OSSEndpoint
	bucketName := global.Cfg.OSSBucketName

	// 初始化OSS客户端
	client, err := oss.New(endpoint, accessKeyID, accessKeySecret)
	if err != nil {
		global.Logger.Fatalf("无法初始化OSS客户端: %v", err)
	}
	// 获取存储桶
	global.OSSBucket, err = client.Bucket(bucketName)
	if err != nil {
		global.Logger.Fatalf("无法获取OSS存储桶: %v", err)
	}
}
